package besta.moon.sql.expression.function.numeric;

import besta.moon.sql.expression.function.FunctionReturnFloat;
import besta.moon.sql.parser.SQLTokenizer;

public final class FunctionLog10 extends FunctionReturnFloat {

    private static final double divisor = Math.log(10);

    @Override
    public final int getFunction() {
        return SQLTokenizer.LOG10;
    }

    @Override
    public final double getDouble() throws Exception {
        if (isNull()) {
            return 0;
        }
        return Math.log(param1.getDouble()) / divisor;
    }

}
